package org.esk.dablog.model;

import javax.persistence.*;

/**
 * This class
 * User: jc
 * Date: 24.11.2006
 * Time: 18:24:54
 * $Id:$
 *
 * @hibernate.class
 *   table="PICTURES"
 *   lazy="true"
 */
@Entity
@Table(name = "PICTURES")
public class Picture {
    private long id;
    private String name;
    private String originalFilename;
    private String description;
    private String localPath;
    private String thumbnailPath;

    private Author author;

    private Entry entry;

    private transient byte[] data;


    /**
     * @hibernate.id
     *   column="ID"
     *   generator-class="native"
     * @hibernate.generator-param
     *   name="sequence"
     *   value="SEQ_PICTURES"
     * @return
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PICTURES")
    @SequenceGenerator(name = "SEQ_PICTURES", sequenceName = "seq_pictures")
    @Column(name = "ID")
    public long getId() {
        return id;
    }

    /**
     * @hibernate.property
     *   column="PICTURE_NAME"
     * @return
     */
    @Column(name="PICTURE_NAME")
    public String getName() {
        return name;
    }

    /**
     * @hibernate.property
     *   column="ORIGINAL_FILENAME"
     * @return
     */
    @Column(name="ORIGINAL_FILENAME")
    public String getOriginalFilename() {
        return originalFilename;
    }

    /**
     * @hibernate.property
     *   column="DESCRIPTION"
     * @return
     */
    @Column(name="DESCRIPTION")
    public String getDescription() {
        return description;
    }

    /**
     * @hibernate.property
     *   column="LOCAL_PATH"
     * @return
     */
    @Column(name="LOCAL_PATH")
    public String getLocalPath() {
        return localPath;
    }


    /**
     * @hibernate.many-to-one
     *   column="ENTRY_ID"
     *   not-null="true"
     *   foreign-key="FK_PICTURE_ENTRY"
     * @return
     */
    @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
    @JoinColumn(name = "ENTRY_ID")
    public Entry getEntry() {
        return entry;
    }

    /**
     * @hibernate.property
     *   column="THUMBNAIL_PATH"
     * @return
     */
    @Column(name="THUMBNAIL_PATH")
    public String getThumbnailPath() {
        return thumbnailPath;
    }


    /**
     * @hibernate.many-to-one
     *   column="AUTHOR_ID"
     *   not-null="true"
     *   foreign-key="FK_PICTURE_AUTHOR"
     * @return
     */
    @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
    @JoinColumn(name = "AUTHOR_ID")
    public Author getAuthor() {
        return author;
    }

    public void setAuthor(Author author) {
        this.author = author;
    }

    public void setThumbnailPath(String thumbnailPath) {
        this.thumbnailPath = thumbnailPath;
    }

    public void setEntry(Entry entry) {
        this.entry = entry;
    }

    public byte[] getData() {
        return data;
    }


    public void setId(long id) {
        this.id = id;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setOriginalFilename(String originalFilename) {
        this.originalFilename = originalFilename;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public void setLocalPath(String localPath) {
        this.localPath = localPath;
    }

    public void setData(byte[] data) {
        this.data = data;
    }
}
